# -- coding: utf-8 -- 
# Name: 7_1_execute_remote_telnet_cmd

import getpass, sys, telnetlib

HOST = "127.0.0.1"

user = raw_input("username:")
password = getpass.getpass()
session = telnetlib.Telnet(HOST)
session.read_until("login:")
session.write(user + "\n")
if password:
    session.read_until("password: ")
    session.write(password + "\n")
session.write("ls\n")
session.write("exit\n")
print session.read_all()